package cn.com.code.generator.controller;

import cn.com.code.generator.service.UserService;
import cn.com.code.generator.vo.PortalToDoStatisticsRequest;
import cn.com.code.generator.vo.SaveUserReqVO;
import cn.com.code.generator.vo.UserReqPageVO;
import cn.com.code.generator.vo.UserRespPageVO;
import cn.com.do1.dsf.common.annotation.SysLog;
import cn.com.do1.dsf.common.validator.group.AddGroup;
import cn.com.do1.dsf.common.web.BaseRestController;
import cn.com.do1.dsf.compont.mysql.utils.PageUtils;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * 
 *
 * @author nick
 * @email sunlightcs@gmail.com
 * @date 2021-05-02 13:03:03
 */
@Api(tags = "")
@RestController
@RequestMapping("/user")
public class UserController extends BaseRestController {
    @Autowired
    private UserService userService;
    /**
     * 分页查询领导列表
     * @param params
     * @return
     */
    @SysLog(value="分页查询用户列表")
    @ApiOperation("分页查询用户列表")
    @RequestMapping(value = "/searchUserPage", method = RequestMethod.POST)
    public PageUtils<UserRespPageVO> searchUserPage(@RequestBody UserReqPageVO params){

        return userService.searchUserPage(params);
    }
    @ApiOperation("分页查询用户列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value="名字", paramType = "query"),
            @ApiImplicitParam(name = "page", value="页码", paramType = "query" ,required = true, defaultValue = "1"),
            @ApiImplicitParam(name = "limit", value="每页条数", paramType = "query",required = true, defaultValue = "10"),
    }
    )
    @RequestMapping(value = "/searchUserPageParam", method = RequestMethod.POST)
    public PageUtils<UserRespPageVO> searchUserPageParam(@ApiIgnore @RequestParam Map<String, Object> params){
        PageUtils<UserRespPageVO> page = userService.searchUserPageParam(params);

        return page;
    }
    /**
     * 保存企业自主填报
     */
    @SysLog("保存用户")
    @ApiOperation("保存用户")
    @RequestMapping(value = "/saveUser", method = RequestMethod.POST)
    public List<String> saveUser(@Validated(AddGroup.class) @RequestBody SaveUserReqVO users){
        return userService.saveUser(users);
    }
    /**
     * 保存企业自主填报
     */
    @SysLog("保存用户")
    @ApiOperation("保存用户")
    @RequestMapping(value = "/saveUser1", method = RequestMethod.POST)
    public void saveUser1(@Validated(AddGroup.class) @RequestBody PortalToDoStatisticsRequest portalToDoStatisticsRequest){
        logger.info("portalToDoStatisticsRequest={}", JSONObject.toJSONString(portalToDoStatisticsRequest));
    }
}
